import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterdemo/0demo/main_page.dart';
import 'package:flutterdemo/0demo/route/route_test_page.dart';

import 'route_test_page2.dart';
import 'routes_name.dart';

/// this way only use material or cupertino style page route.
/// do not use this way.
var routePath = {
  "${RoutesName.ROUTE_TEST_PAGE}": (context) => RouteTestPage(),
};

/// custom page routes, use this way.
pageRoute(RouteSettings routeSettings) {
  Widget page;
  switch (routeSettings.name) {
    case RoutesName.MAIN_PAGE:
      page = MainPage();
      break;
    case RoutesName.ROUTE_TEST_PAGE:
      page = RouteTestPage(routeParams: routeSettings.arguments);
      break;
    case RoutesName.ROUTE_TEST_PAGE2:
      page = RouteTestPage2.withParam(params: routeSettings.arguments);
      break;
  }
  if (page != null) {
    return CupertinoPageRoute(builder: (_) => page, settings: routeSettings);
  }
  return null;
}
